import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

public class TreeMapDemo {
    static class A implements Comparable<A> {
        int value = 0;

        public A(int value) {
            this.value = value;
        }

        public int compareTo(A o) {
            if (value == o.value) return 0;
            return value > o.value ? 1 : -1;
        }
    }


    public static void main(String[] args) {
        Map map = new TreeMap();
        map.put(1, new A(1));
        map.put(2, new A(2));
    }
}
